package br.com.troca.carro.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import br.com.troca.carro.vo.Bens;
import br.com.troca.carro.vo.DesejosVO;

@Repository
public class BensDAOImpl implements BensDAO {
	
	@Autowired
	private SessionFactory sessionFactory;
	
	@Transactional
	public void incluir(Bens objeto) {
		sessionFactory.getCurrentSession().save(objeto);
	}

	@Transactional
	public void alterar(Bens objeto) {
		sessionFactory.getCurrentSession().update(objeto);
	}

	@Transactional
	public void excluir(Bens objeto) {
		sessionFactory.getCurrentSession().delete(objeto);
	}

	@Override
	@Transactional(propagation=Propagation.REQUIRES_NEW)
	public Bens detalhar(Bens objeto) {
		return (Bens)sessionFactory.getCurrentSession().get(Bens.class, objeto.getId());		
	}
	
	@Transactional
	public List<Bens> pesquisarBensPorFiltro(Bens bens) {
		return null;
	}

	@Transactional
	public List<Bens> listarBensPorDesejo(List<DesejosVO> desejos) {
		return null;
	}

}
